package fivestar.ui.user;

import java.awt.Color;
import java.awt.Font;
import java.awt.Frame;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JPasswordField;
import javax.swing.JSeparator;
import javax.swing.JTextField;
import javax.swing.SwingConstants;
import javax.swing.SwingUtilities;

import org.netbeans.validation.api.ValidatorUtils;
import org.netbeans.validation.api.builtin.stringvalidation.StringValidators;
import org.netbeans.validation.api.ui.ValidationGroup;
import org.netbeans.validation.api.ui.swing.ValidationPanel;

public class ChangePassword extends javax.swing.JDialog implements ActionListener{

	private static final long serialVersionUID = 1460828511022534236L;
 
    private JButton btnAdd,btnCancel;
    private JLabel confirmacionErroneo;
    private JLabel confirmacionOk;
    private JPasswordField txtConfirmPassword;
    private JLabel contraseniaAnteriorErroneo;
    private JLabel contraseniaAnteriorOk;
    private JLabel contraseniaErroneo;
    private JLabel contraseniaOk;
    private JLabel lblCurrentPassword;
    private JLabel lblConfirmNewPassword;
    private JLabel lblNewPassword;
    private JLabel lblUserName;
    private JLabel lblNewLabel, lblUser;
    private JPanel pnlUser,pnlTitle,pnlOption,pnlChange;
    private JPasswordField txtCurrentPassword;
    private JPasswordField txtNewPassword;
    private JTextField txtUserName;
    private JSeparator separator;
    ValidationPanel pnlValidation;
	ValidationGroup group;
    
	public ChangePassword(Frame parent, boolean modal) {
		super(parent, modal);
		setResizable(false);
		initComponents();
		this.setLocationRelativeTo(null);
	}
	
	@SuppressWarnings("unchecked")
	private void initComponents() {
		try {			
			getContentPane().setLayout(null);
			
			pnlUser = new  JPanel();
			pnlUser.setBounds(0, 0, 466, 275);
	        pnlUser.setLayout(null);
	        getContentPane().add(pnlUser);
	        
	        pnlValidation = new ValidationPanel();
			pnlValidation.setBounds(0, 0, 476, 287);
			pnlValidation.setInnerComponent(pnlUser);
			getContentPane().add(pnlValidation);
			group = pnlValidation.getValidationGroup();
	        
	        pnlTitle = new JPanel();
			pnlTitle.setForeground(new Color(0, 0, 0));
			pnlTitle.setBounds(10, 0, 448, 67);
			pnlUser.add(pnlTitle);
			pnlTitle.setLayout(null);
			
			lblUser = new JLabel("User");
			lblUser.setHorizontalAlignment(SwingConstants.LEFT);
			lblUser.setVerticalAlignment(SwingConstants.TOP);
			lblUser.setFont(new Font("Tahoma", Font.PLAIN, 30));
			lblUser.setBounds(10, 0, 342, 38);
			pnlTitle.add(lblUser);
			
			separator = new JSeparator();
			separator.setBounds(5, 36, 594, 2);
			pnlTitle.add(separator);

			lblNewLabel = new JLabel("Change Password");
			lblNewLabel.setHorizontalAlignment(SwingConstants.LEFT);
			lblNewLabel.setVerticalAlignment(SwingConstants.BOTTOM);
			lblNewLabel.setForeground(new Color(0, 0, 0));
			lblNewLabel.setFont(new Font("Tahoma", Font.PLAIN, 20));
			lblNewLabel.setBounds(10, 36, 342, 27);
			pnlTitle.add(lblNewLabel);
			
			pnlChange = new JPanel();
			pnlChange.setForeground(new Color(0, 0, 0));
			pnlChange.setBounds(10, 73, 446, 138);
			pnlUser.add(pnlChange);
			pnlChange.setLayout(null);
			
		    lblUserName = new JLabel();
		    lblUserName.setHorizontalAlignment(SwingConstants.RIGHT);
	        lblUserName.setBounds(26, 11, 170, 20);
	        lblUserName.setText("User Name :");
	        pnlChange.add(lblUserName);
	        
	        txtUserName = new  JTextField();
	        txtUserName.setBounds(206, 11, 210, 20);
	        txtUserName.setEnabled(false);
	        pnlChange.add(txtUserName);	        
	        
	        lblCurrentPassword = new JLabel();
	        lblCurrentPassword.setHorizontalAlignment(SwingConstants.RIGHT);
	        lblCurrentPassword.setBounds(26, 41, 170, 20);
	        lblCurrentPassword.setText("Current Password :");
	        pnlChange.add(lblCurrentPassword);	        
	        
	        txtCurrentPassword = new JPasswordField();
	        txtCurrentPassword.setBounds(206, 41, 210, 20);
	        txtCurrentPassword.setName("Current Password");
	        pnlChange.add(txtCurrentPassword); 
	        
	        contraseniaAnteriorErroneo = new JLabel();
	        contraseniaAnteriorErroneo.setBounds(426, 41, 20, 20);
	        contraseniaAnteriorErroneo.setText("Ca");
	        pnlChange.add(contraseniaAnteriorErroneo); 
	        
	        contraseniaAnteriorOk = new JLabel();
	        contraseniaAnteriorOk.setBounds(426, 41, 10, 20);
	        contraseniaAnteriorOk.setText("Ok");
	        pnlChange.add(contraseniaAnteriorOk);
	        
	        lblNewPassword = new JLabel();	        
	        lblNewPassword.setHorizontalAlignment(SwingConstants.RIGHT);
	        lblNewPassword.setBounds(26, 71, 170, 20);
	        lblNewPassword.setText("New Password :");
	        pnlChange.add(lblNewPassword);
	        
	        txtNewPassword = new JPasswordField();
	        txtNewPassword.setBounds(206, 71, 210, 19);
	        txtNewPassword.setName("New Password");
	        pnlChange.add(txtNewPassword);	        
	        
	        contraseniaErroneo = new JLabel();
	        contraseniaErroneo.setBounds(426, 71, 20, 20);
	        contraseniaErroneo.setText("Ca");
	        pnlChange.add(contraseniaErroneo);
	        
	        contraseniaOk = new JLabel();
	        contraseniaOk.setBounds(426, 71, 10, 20);
	        contraseniaOk.setText("Ok");
	        pnlChange.add(contraseniaOk);

	        lblConfirmNewPassword = new JLabel();
	        lblConfirmNewPassword.setHorizontalAlignment(SwingConstants.RIGHT);
	        lblConfirmNewPassword.setBounds(26, 101, 170, 20);
	        lblConfirmNewPassword.setText("Confirm New Password :");
	        pnlChange.add(lblConfirmNewPassword);
	        
	        txtConfirmPassword = new JPasswordField();
	        txtConfirmPassword.setBounds(206, 101, 210, 20);
	        txtConfirmPassword.setName("Confirm Password");
	        pnlChange.add(txtConfirmPassword);
	        
	        confirmacionErroneo = new JLabel();
	        confirmacionErroneo.setBounds(426, 101, 20, 20);
	        confirmacionErroneo.setText("Ca");
	        pnlChange.add(confirmacionErroneo);
	        
	        confirmacionOk = new JLabel();
	        confirmacionOk.setBounds(426, 101, 10, 20);
	        confirmacionOk.setText("Ok");
	        pnlChange.add(confirmacionOk);
	        
	        pnlOption = new JPanel();
			pnlOption.setBounds(10, 218, 446, 30);
			pnlUser.add(pnlOption);
			pnlOption.setLayout(null);

			btnAdd = new JButton("Add");
			btnAdd.setEnabled(false);
			btnAdd.setBounds(203, 0, 98, 28);
			pnlOption.add(btnAdd);
			btnAdd.setFont(new Font("Tahoma", Font.PLAIN, 10));
			btnAdd.addActionListener(this);

			btnCancel = new JButton("Cancel");
			btnCancel.setBounds(309, 0, 98, 28);
			pnlOption.add(btnCancel);
			btnCancel.setFont(new Font("Tahoma", Font.PLAIN, 10));
			btnCancel.addActionListener(this);  

			group.add(txtConfirmPassword, ValidatorUtils.merge(StringValidators.REQUIRE_NON_EMPTY_STRING));	
			group.add(txtNewPassword, ValidatorUtils.merge(StringValidators.REQUIRE_NON_EMPTY_STRING));	
			group.add(txtCurrentPassword, ValidatorUtils.merge(StringValidators.REQUIRE_NON_EMPTY_STRING));
			
	        setSize(482, 315);
	        
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
	
	public static void main(String[] args) {
		SwingUtilities.invokeLater(new Runnable() {
			public void run() { 
				ChangePassword inst = new ChangePassword(null, true);
				inst.setVisible(true);
			}
		});
	}

	@Override
	public void actionPerformed(ActionEvent e) {
		// TODO Auto-generated method stub
		
	}

}
